<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />

        <link rel="icon" type="image/svg+xml" href="/logo.svg" />

        <!-- 主题色定义 -->
        <meta name="theme-color" content="#6a6de6" />

        <!-- SEO元标签 -->
        <meta
            name="description"
            content="AI Proxy"
        />
        <meta
            name="keywords"
            content="AI, proxy, security, protection"
        />

        <!-- 社交媒体分享信息 -->
        <meta property="og:title" content="AI Proxy" />
        <meta property="og:description" content="AI Proxy" />
        <meta property="og:image" content="/og-image.png" />



        <!-- 添加页面加载样式，避免初始白屏 -->
        <style>
            /* 基础样式重置 */
            body,
            html {
                margin: 0;
                padding: 0;
                height: 100%;
                width: 100%;
                overflow: hidden;
                font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
                    Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans",
                    "Helvetica Neue", sans-serif;
            }

            #root {
                height: 100%;
                width: 100%;
            }

            /* 加载动画样式 */
            .app-loading {
                position: fixed;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                z-index: 9999;
            }

            /* 使用蓝紫色渐变背景 */
            .app-loading-background {
                position: absolute;
                inset: 0;
                background: linear-gradient(
                    135deg,
                    rgba(106, 109, 230, 0.95) 0%,
                    rgba(123, 127, 246, 0.9) 50%,
                    rgba(138, 141, 247, 0.95) 100%
                );
                background-size: 200% 200%;
            }

            .app-loading-blur-elements {
                position: absolute;
                inset: 0;
                overflow: hidden;
            }

            .app-loading-blur-1 {
                position: absolute;
                width: 80%;
                height: 80%;
                top: 10%;
                left: 10%;
                background-color: rgba(255, 255, 255, 0.1); /* white/10 */
                border-radius: 9999px;
                filter: blur(24px);
                animation: preload-float 8s ease-in-out infinite;
            }

            .app-loading-blur-2 {
                position: absolute;
                width: 40%;
                height: 40%;
                top: 5%;
                right: 15%;
                background-color: rgba(255, 255, 255, 0.15); /* 调整为更接近原AI-Proxy文件 */
                border-radius: 9999px;
                filter: blur(24px);
                animation: preload-float-reverse 9s ease-in-out infinite;
            }

            .app-loading-blur-3 {
                position: absolute;
                width: 50%;
                height: 50%;
                bottom: 5%;
                left: 15%;
                background-color: rgba(255, 255, 255, 0.1); /* 调整为更接近原AI-Proxy文件 */
                border-radius: 9999px;
                filter: blur(24px);
                animation: preload-pulse-glow 4s ease-in-out infinite;
            }

            /* 进度条容器 */
            .app-loading-content {
                position: relative;
                z-index: 10;
                display: flex;
                flex-direction: column;
                align-items: center;
                gap: 32px; /* 保持原间距 */
            }

            .app-loading-text {
                color: white;
                font-size: 24px;
                font-weight: 500;
                animation: preload-fade-in 0.5s ease-out;
            }

            .app-loading-progress-container {
                width: 256px;
                height: 8px;
                background-color: rgba(255, 255, 255, 0.2);
                border-radius: 9999px;
                overflow: hidden;
            }

            .app-loading-progress-bar {
                height: 100%;
                width: 0%;
                border-radius: 9999px;
                background: linear-gradient(
                    90deg,
                    rgba(255, 255, 255, 0.9) 0%,
                    rgba(255, 255, 255, 0.7) 100%
                );
                box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
                transition: width 0.3s ease;
            }

            .app-loading-percentage {
                color: rgba(255, 255, 255, 0.8);
                font-size: 14px;
                animation: preload-pulse 2s infinite;
            }

            /* 添加粒子效果 */
            .app-loading-particle {
                position: absolute;
                border-radius: 9999px;
                background-color: rgba(255, 255, 255, 0.1);
                animation: preload-float 15s ease-in-out infinite;
            }

            /* 定义动画关键帧 */
            @keyframes preload-float {
                0%,
                100% {
                    transform: translateY(0) scale(1);
                }
                50% {
                    transform: translateY(-20px) scale(1.05);
                }
            }

            @keyframes preload-float-reverse {
                0%,
                100% {
                    transform: translateY(0) scale(1);
                }
                50% {
                    transform: translateY(20px) scale(1.05);
                }
            }

            @keyframes preload-pulse-glow {
                0%,
                100% {
                    opacity: 0.6;
                    transform: scale(1);
                }
                50% {
                    opacity: 0.8;
                    transform: scale(1.1);
                }
            }

            @keyframes preload-pulse {
                0%,
                100% {
                    opacity: 0.5;
                }
                50% {
                    opacity: 1;
                }
            }

            @keyframes preload-fade-in {
                from {
                    opacity: 0;
                    transform: translateY(-20px);
                }
                to {
                    opacity: 1;
                    transform: translateY(0);
                }
            }

            /* 隐藏加载动画，当应用加载完成时使用 */
            .app-loading-hidden {
                opacity: 0;
                visibility: hidden;
                transition: opacity 0.5s, visibility 0.5s;
            }
        </style>

        <title>AI Proxy</title>
    </head>
    <body>
        <div id="root">
            <!-- 应用加载前显示的加载指示器 -->
            <div id="app-loading-screen" class="app-loading">
                <div class="app-loading-background"></div>
                <div class="app-loading-blur-elements">
                    <div class="app-loading-blur-1"></div>
                    <div class="app-loading-blur-2"></div>
                    <div class="app-loading-blur-3"></div>
                    
                    <!-- 粒子效果 - 动态生成 -->
                    <script>
                        // 动态创建25个粒子元素
                        for (let i = 0; i < 25; i++) {
                            const particle = document.createElement("div");
                            particle.className = "app-loading-particle";
                            const size = Math.random() * 6 + 2;

                            particle.style.width = `${size}px`;
                            particle.style.height = `${size}px`;
                            particle.style.top = `${Math.random() * 100}%`;
                            particle.style.left = `${Math.random() * 100}%`;
                            particle.style.animationDelay = `${
                                Math.random() * 5
                            }s`;

                            document.currentScript.parentNode.appendChild(
                                particle
                            );
                        }
                    </script>
                </div>
                <div class="app-loading-content">
                    <div class="app-loading-text">Loading...</div>
                    <div class="app-loading-progress-container">
                        <div
                            class="app-loading-progress-bar"
                            id="progressBar"
                        ></div>
                    </div>
                    <div class="app-loading-percentage" id="progressText">
                        0% Complete
                    </div>
                </div>
            </div>
        </div>
        <script>
            // Match the React component's progress calculation logic exactly
            (function () {
                const progressBar = document.getElementById("progressBar");
                const progressText = document.getElementById("progressText");
                let progress = 0;

                const timer = setInterval(() => {
                    // Slow down as it approaches 100%
                    // 使用Math.floor确保结果是整数
                    const increment = Math.floor(
                        Math.max(1, 10 * (1 - progress / 100))
                    );
                    progress = Math.min(99, progress + increment);
                    // 确保最终结果也是整数
                    progress = Math.floor(progress);

                    // Update the DOM
                    progressBar.style.width = `${progress}%`;
                    progressText.textContent = `${progress}% Complete`;

                    if (progress >= 99) {
                        clearInterval(timer);
                    }
                }, 200);
            })();
        </script>
        <script type="module" src="/src/main.tsx"></script>
    </body>
</html>
